﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pgAdmAO.aspx.cs" Inherits="EGuayas.Web.Auditoria.Promotor.Otro.pgAdmAO" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title><link  href="~/Resources/css/Style.css"  rel="stylesheet" /><!-- Load Ext JS --> <script src="../../../Resources/js/Global.js"></script>
</head>
<body>
    <ext:ResourceManager ID="ResourceManager1" runat="server"></ext:ResourceManager>
    <ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout">
        <Items>
            <ext:Panel ID="Panel1" runat="server" Region="North" BodyPadding="6"
                TitleCollapse="false" ButtonAlign="Center" Border="false">
                <Items>
                    <ext:Panel ID="panC1" runat="server" Layout="ColumnLayout" Border="false">
                        <Items>
                            <ext:Panel ID="panC1Col1" runat="server" ColumnWidth=".33" Border="false">
                                <Items>
                                    <ext:ComboBox ID="cbbProvincia" runat="server" FieldLabel="Provincia" ValueField="Id" DisplayField="Nombre">
                                        <Store>
                                            <ext:Store runat="server" ID="stoProvincia">
                                                <Model>
                                                    <ext:Model ID="Model3" runat="server" IDProperty="Id">
                                                        <Fields>
                                                            <ext:ModelField Name="Id"></ext:ModelField>
                                                            <ext:ModelField Name="Nombre"></ext:ModelField>
                                                        </Fields>
                                                    </ext:Model>
                                                </Model>
                                            </ext:Store>
                                        </Store>
                                        <Triggers>
                                            <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                        </Triggers>
                                        <Listeners>
                                            <Select Handler="this.getTrigger(0).show();" />
                                            <BeforeQuery Handler="this.getTrigger(0)[this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                            <TriggerClick Handler="if (index == 0) { 
                                           this.clearValue(); 
                                           this.getTrigger(0).hide();
                                       }" />
                                        </Listeners>
                                        <DirectEvents>
                                            <Select OnEvent="cbbProvincia_Select">
                                                <ExtraParams>
                                                    <ext:Parameter Name="Id" Value="#{cbbProvincia}.getValue()" Mode="Raw"/>
                                                </ExtraParams>
                                                <EventMask ShowMask="True"></EventMask>
                                            </Select>
                                        </DirectEvents>
                                    </ext:ComboBox>
                                    <ext:TextField ID="txtCodigo" runat="server" FieldLabel="Código"></ext:TextField>
                                </Items>
                            </ext:Panel>
                            <ext:Panel ID="panC1Col2" runat="server" ColumnWidth=".33" Border="false">
                                <Items>
                                    <ext:ComboBox ID="cbbCanton" runat="server" FieldLabel="Cantón" ValueField="Id" DisplayField="Nombre">
                                        <Store>
                                            <ext:Store runat="server" ID="stoCanton">
                                                <Model>
                                                    <ext:Model ID="Model4" runat="server" IDProperty="Id">
                                                        <Fields>
                                                            <ext:ModelField Name="Id"></ext:ModelField>
                                                            <ext:ModelField Name="Nombre"></ext:ModelField>
                                                        </Fields>
                                                    </ext:Model>
                                                </Model>
                                            </ext:Store>
                                        </Store>
                                        <Triggers>
                                            <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                        </Triggers>
                                        <Listeners>
                                            <Select Handler="this.getTrigger(0).show();" />
                                            <BeforeQuery Handler="this.getTrigger(0)[this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                            <TriggerClick Handler="if (index == 0) { 
                                           this.clearValue(); 
                                           this.getTrigger(0).hide();
                                       }" />
                                        </Listeners>
                                        <DirectEvents>
                                            <Select OnEvent="cbbCanton_Select">
                                                <ExtraParams>
                                                    <ext:Parameter Name="Id" Value="#{cbbCanton}.getValue()" Mode="Raw"/>
                                                </ExtraParams>
                                                <EventMask ShowMask="True"></EventMask>
                                            </Select>
                                        </DirectEvents>
                                    </ext:ComboBox>
                                    <ext:TextField ID="txtNombre" runat="server" FieldLabel="Nombre"></ext:TextField>
                                </Items>
                            </ext:Panel>
                            <ext:Panel ID="panC1Col3" runat="server" ColumnWidth=".33" Border="false">
                                <Items>
                                    <ext:ComboBox ID="cbbParroquia" runat="server" FieldLabel="Parroquia" ValueField="Id" DisplayField="Nombre">
                                        <Store>
                                            <ext:Store runat="server" ID="stoParroquia">
                                                <Model>
                                                    <ext:Model ID="Model5" runat="server" IDProperty="Id">
                                                        <Fields>
                                                            <ext:ModelField Name="Id"></ext:ModelField>
                                                            <ext:ModelField Name="Nombre"></ext:ModelField>
                                                        </Fields>
                                                    </ext:Model>
                                                </Model>
                                            </ext:Store>
                                        </Store>
                                        <Triggers>
                                            <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                        </Triggers>
                                        <Listeners>
                                            <Select Handler="this.getTrigger(0).show();" />
                                            <BeforeQuery Handler="this.getTrigger(0)[this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                            <TriggerClick Handler="if (index == 0) { 
                                           this.clearValue(); 
                                           this.getTrigger(0).hide();
                                       }" />
                                        </Listeners>
                                    </ext:ComboBox>
                                </Items>
                            </ext:Panel>
                        </Items>
                    </ext:Panel>
                </Items>
                <Buttons>
                    <ext:Button ID="btnBuscar" runat="server" Text="Buscar">
                        <DirectEvents>
                            <Click OnEvent="btnBuscar_Click">
                                <ExtraParams>
                                    <ext:Parameter Name="Codigo" Value="#{txtCodigo}.getValue()" Mode="Raw"/>
                                    <ext:Parameter Name="Nombre" Value="#{txtNombre}.getValue()" Mode="Raw"/>
                                    <ext:Parameter Name="ProvinciaId" Value="#{cbbProvincia}.getValue()==null?'':#{cbbProvincia}.getValue()" Mode="Raw"/>
                                    <ext:Parameter Name="CantonId" Value="#{cbbCanton}.getValue()==null?'':#{cbbCanton}.getValue()" Mode="Raw"/>
                                    <ext:Parameter Name="ParroquiaId" Value="#{cbbParroquia}.getValue()==null?'':#{cbbParroquia}.getValue()" Mode="Raw"/>
                                </ExtraParams>
                                <EventMask ShowMask="True"></EventMask>
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Buttons>
            </ext:Panel>
            <ext:GridPanel runat="server" ID="gpnAuditoria" Title="Expedientes de Licencias para control y seguimiento"
                Region="Center">
                <Store>
                    <ext:Store runat="server" ID="stoExpedienteAud">
                        <Model>
                    <ext:Model ID="Model2" runat="server" IDProperty="Id" >
                        <Fields>
                            <ext:ModelField Name="Id"/>
                            <ext:ModelField Name="ExpedienteId" />
                            <ext:ModelField Name="Nombre"/>
                            <ext:ModelField Name="Regulado"/>
                            <ext:ModelField Name="Descripcion"/>
                            <ext:ModelField Name="Estado"/>
                            <ext:ModelField Name="Fase"/>
                        </Fields>
                    </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel>
                    <Columns>
                        <ext:Column runat="server" Text="Nombre" Flex="1" DataIndex="Nombre" />
                        <ext:Column runat="server" Text="Regulado" DataIndex="Regulado" Width="120" />
                        <ext:Column runat="server" Text="Descripción" DataIndex="Descripcion" Width="150" />
                        <ext:Column runat="server" Text="Estado" DataIndex="Estado" Width="80" />
                        <ext:Column runat="server" Text="Fase" DataIndex="Fase" Width="80" />
                        
                    </Columns>
                </ColumnModel>
                <DirectEvents>
                    <Select OnEvent="gpnAuditoria_Select">
                        <EventMask ShowMask="True"></EventMask>
                        <ExtraParams>
                            <ext:Parameter Name="Id" Value="record.data.ExpedienteId" Mode="Raw"/>
                        </ExtraParams>
                    </Select>
                </DirectEvents>
            </ext:GridPanel>
            <ext:GridPanel runat="server" ID="gpnAuditoriaMonitoreo" Region="South" Height="130">
        
                <Store>
                    <ext:Store runat="server" ID="stoAM">
                        <Model>
                    <ext:Model ID="Model1" runat="server" IDProperty="Id" >
                        <Fields>
                            <ext:ModelField Name="Id"/>
                            <ext:ModelField Name="ExpedienteId" />
                            <ext:ModelField Name="Nombre"/>
                            <ext:ModelField Name="Promotor"/>
                            <ext:ModelField Name="Descripcion"/>
                            <ext:ModelField Name="Estado" />
                            <ext:ModelField Name="FechaInicio"  Type="Date"/>
                            <ext:ModelField Name="FechaFin" Type="Date"/>
                            <ext:ModelField Name="EstadoFase" />
                             <ext:ModelField Name="Alias" />

                        </Fields>
                    </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel>
                    <Columns>
                        <ext:Column ID="Column1"  runat="server" Text="Auditoria" Flex="1" DataIndex="Nombre" />
                        <ext:Column ID="Column2"  runat="server" Text="Nombre" Flex="1" DataIndex="Alias" />
                        <ext:Column runat="server" Text="Promotor" DataIndex="Promotor" Width="120" />
                        <ext:Column runat="server" Text="Descripción" DataIndex="Descripcion" Width="150" />
                       
                        <ext:Column runat="server" Text="Estado" Width="80" DataIndex="EstadoFase">
                           <%-- <Renderer Fn="pgFnAdmin.FormatEstado" />--%>
                        </ext:Column>
                        <ext:DateColumn runat="server"  Text="Fecha Inicio"    DataIndex ="FechaInicio"   />
                        <ext:DateColumn runat="server"  Text="Fecha Fin"       DataIndex ="FechaFin"   />
                         
                        <ext:CommandColumn  runat="server" Width="80" >
                            <Commands>
                            <ext:GridCommand Icon="TableGo" CommandName="VerProceso">
                                <ToolTip Text="Ver Auditoria" />
                            </ext:GridCommand>
                            <ext:CommandSeparator />
                        </Commands>
                            <Listeners>
                                <Command Handler="pgFnAdmin.winUrl =AppGlobalJs.mostrarVentanaUrl('pgOtros.aspx?estado='+record.data.EstadoFase+'&ots_id='+record.data.Id+'&exp_id='+record.data.ExpedienteId,'Nueva Auditoria','#ApplicationFormAdd');"></Command>
                            </Listeners>
                        </ext:CommandColumn>
                        
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
        </Items>
    </ext:Viewport>
    <ext:XScript ID="XScript1" runat="server">
        <script type="text/javascript">
            var pgFnAdmin = new Object();
            pgFnAdmin.winUrl = null;
            pgFnAdmin.FormatEstado = function (value) {
                var template = '<span>{0}</span>';
                return Ext.String.format(template, (value == "N") ? "No" : "Si", value);

            };
            pgFnAdmin.ShowNuevoExpediente = function () {
                var objSelect = App.gpnAuditoria.getRowsValues({ selectedOnly: true });
                if (objSelect.length != 0) {
                    var rowSelect = objSelect[0];
                    pgFnAdmin.winUrl = AppGlobalJs.mostrarVentanaUrl('pgNuevoExpediente.aspx?evt=NUEVO&estado=' + rowSelect.EstadoFase + '&exp_id=' + rowSelect.ExpedienteId + '&exa_id=' + rowSelect.Id, 'Nuevo Expediente', '#ApplicationViewTile');
                    //
                    //console.log('pgNuevoExpediente.aspx?evt=NUEVO&exp_id=' + rowSelect.ExpedienteId + '&exa_id=' + rowSelect.Id, 'Nuevo Expediente', '#ApplicationViewTile');
                }

            };
            //Cerrar ventana creada
            App.CloseNuevoExpediente = function () {
                AppGlobalJs.closeVentanaUrl(pgFnAdmin.winUrl);
                
            };
        </script>
    </ext:XScript>
</body>
</html>
